/**
 * 描述: 服务-客服中心
 * 版权: Copyright (c) 2019
 * 公司: 深圳市网商天下科技开发有限公司
 * 作者: 许堉颖
 * 版本: 1.0.0
 * 创建时间: 2019/04/29 16:52
 */
import {Service, RequestParams} from 'vue-element-simple';

// ====================客服联系信息
/**
 * 获取客服联系信息
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetCustomerServiceConfig = async function () {
  const request = new RequestParams();
  return await this.getService(`/admin/system/getConfig/customerService`, request);
};

/**
 * 更新客服联系信息
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationUpdateCustomerServiceConfig = async function (params = {}) {
  const request = new RequestParams();
  // 境内电话
  request.put('territoryTel', params['territoryTel']).checkEmpty('境内电话');
  // 境外电话
  request.put('abroadTel', params['abroadTel']).checkEmpty('境外电话');
  return await this.getService(`/admin/system/saveConfig/customerService`, request);
};
// ====================客服联系信息

// ====================文章栏目管理
/**
 * 分页获取栏目列表
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetArticleTypeList = async function (params = {}) {
  const request = new RequestParams();
  // 页数
  request.put('page', params['page'], 1);
  // 每页条数
  request.put('pageSize', params['pageSize'], 20);
  // 模糊搜索标题
  request.put('name', params['name']);
  // 状态
  request.put('status', params['status']);
  return await this.getService(`/admin/articleType/getPageList`, request);
};

/**
 * 获取所有栏目列表
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetAllArticleTypeList = async function () {
  const request = new RequestParams();
  return await this.getService(`/admin/articleType/getChoose`, request);
};

/**
 * 根据id获取栏目信息
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetArticleTypeDetails = async function (params = {}) {
  const request = new RequestParams();
  // id
  request.put('id', params['id'], 1);
  return await this.getService(`/admin/articleType/getDetailsById`, request);
};
/**
 * 添加栏目
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationAddArticleType = async function (params = {}) {
  const request = new RequestParams();
  // 栏目标题
  request.put('name', params['name']).checkEmpty('栏目标题');
  // 栏目图标
  request.put('icon', params['icon']).checkEmpty('栏目图标');
  // 权重
  request.put('orderBy', params['orderBy']).checkEmpty('权重');
  return await this.getService(`/admin/articleType/create`, request);
};

/**
 * 编辑栏目
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationModifyArticleType = async function (params = {}) {
  const request = new RequestParams();
  // 栏目id
  request.put('id', params['id']).checkEmpty('栏目ID');
  // 栏目标题
  request.put('name', params['name']).checkEmpty('栏目标题');
  // 栏目图标
  request.put('icon', params['icon']).checkEmpty('栏目图标');
  // 权重
  request.put('orderBy', params['orderBy']).checkEmpty('权重');
  return await this.getService(`/admin/articleType/update`, request);
};

/**
 * 删除栏目
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationDeleteArticleType = async function (params = {}) {
  const request = new RequestParams();
  // 栏目id
  request.put('id', params['id']).checkEmpty('栏目ID');
  return await this.getService(`/admin/articleType/delete`, request);
};

/**
 * 修改栏目状态
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationChangeArticleTypeStatus = async function (params = {}) {
  const request = new RequestParams();
  // 栏目id
  request.put('id', params['id']).checkEmpty('栏目ID');
  // 状态
  request.put('status', params['status']).checkEmpty('状态');
  return await this.getService(`/admin/articleType/updateStatus`, request);
};

// ====================文章栏目管理

// ====================文章管理
/**
 * 分页获取文章列表
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetArticleList = async function (params = {}) {
  const request = new RequestParams();
  // 类型id
  request.put('id', params['typeId']).checkEmpty('类型id');
  // 页数
  request.put('page', params['page'], 1);
  // 每页条数
  request.put('pageSize', params['pageSize'], 20);
  // 模糊搜索标题
  request.put('title', params['title']);
  // 状态
  request.put('status', params['status']);
  return await this.getService(`/admin/articleType/articleListById`, request);
};

/**
 * 根据id获取文章信息
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationGetArticleDetails = async function (params = {}) {
  const request = new RequestParams();
  // id
  request.put('id', params['id'], 1);
  return await this.getService(`/admin/article/getDetailsById`, request);
};
/**
 * 添加文章
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationAddArticle = async function (params = {}) {
  const request = new RequestParams();
  // 文章标题
  request.put('title', params['title']).checkEmpty('文章标题');
  // 所属栏目
  request.put('typeId', params['typeId']).checkEmpty('所属栏目');
  // 文章内容
  request.put('content', params['content']).checkEmpty('文章内容');
  return await this.getService(`/admin/article/create`, request);
};

/**
 * 编辑文章
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationModifyArticle = async function (params = {}) {
  const request = new RequestParams();
  // 文章id
  request.put('id', params['id']).checkEmpty('文章ID');
  // 文章标题
  request.put('title', params['title']).checkEmpty('文章标题');
  // 所属栏目
  request.put('typeId', params['typeId']).checkEmpty('所属栏目');
  // 文章内容
  request.put('content', params['content']).checkEmpty('文章内容');
  return await this.getService(`/admin/article/update`, request);
};

/**
 * 删除文章
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationDeleteArticle = async function (params = {}) {
  const request = new RequestParams();
  // 文章id
  request.put('id', params['id']).checkEmpty('文章ID');
  return await this.getService(`/admin/article/delete`, request);
};

/**
 * 修改文章状态
 * @param params
 * @returns {Promise.<*>}
 */
Service.applicationChangeArticleStatus = async function (params = {}) {
  const request = new RequestParams();
  // 文章ID
  request.put('id', params['id']).checkEmpty('文章ID');
  // 状态
  request.put('status', params['status']).checkEmpty('状态');
  return await this.getService(`/admin/article/updateStatus`, request);
};

// ====================文章管理
